﻿using Prism.Events;
using Prism.Regions;
using FrameWork.Core.China;
using FrameWork.Core.Resources;
using FrameWork.Core.Chain.Entitys;
using FrameWork.Core.Infrastructure;
using FrameWork.Core.Enum;

namespace FrameWork.Core.Chain.Invengo
{
    public abstract class InvengoNode : IProcessNode
    {
        #region ___属性实现___
        public virtual int[] SupportFlowTypes => new int[0];

        private double m_Order = -1;
        public virtual double Order
        {
            get { return m_Order == -1 ? this.Order : m_Order; }
            set { m_Order = value; }
        }
        private double m_Index = -1;
        public double Index
        {
            get { return m_Index == -1 ? this.Order : m_Index; }
            set { m_Index = value; }
        }
        private double m_NextOrder = -1;

        public virtual double NextOrder
        {
            get { return m_NextOrder; }
            set { m_NextOrder = value; }
        }
        private int m_NodeType = -1;

        public virtual int NodeType
        {
            get { return m_NodeType; }
            set { m_NodeType = value; }
        }
        public virtual string NodeCode { get; set; }
        public virtual string NodeName { get; set; }
        public virtual EnumNodeState State { get; set; }
        #endregion

        #region ___方法实现___
        public virtual void Prepare<P, D>(P processBase, D processDataBase) where P : ProcessBase where D : ProcessDataBase
        {

        }

        public abstract void Process<P, D>(P processBase, D processDataBase) where P : ProcessBase where D : ProcessDataBase;

        public virtual void ClearUp<P, D>(P processBase, D processDataBase) where P : ProcessBase where D : ProcessDataBase
        {

        }

        #endregion

        #region __方法和属性__
        /// <summary>
        /// 事件获取器
        /// </summary>
        public IEventAggregator EventAggregator
        {
            get { return EngineContext.Current.Resolve<IEventAggregator>(); }
        }
        /// <summary>
        /// 获取当前参数
        /// </summary>
        protected NavigationParameters WarpParams(ProcessDataBase record)
        {
            NavigationParameters Params = new NavigationParameters();
            Params.Add(SysResources.Param_ProcessRecord, record);
            return Params;
        }
        #endregion
    }
}
